package com.century.sjt.activity.Pay;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.century.sjt.R;
import com.century.sjt.activity.BaseActivity;
import com.century.sjt.entity.Merchant;
import com.century.sjt.widget.TitleBar.SjtTitleBar;

public class BusinessQualificationActivity extends BaseActivity {

    private RequestQueue mQueue;
    private SjtTitleBar titleBar;
    private Merchant aMerchant;
//    private String imgURL;
//    private GridView gvImage;
//    private QualificationAdapter adapter;
//    private String[] imageUrls;
//    private TextView tCome;
    private WebView mWVcontent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_business_qualification);
        mQueue = Volley.newRequestQueue(this);
        initBundle();
        initView();
        initEvent();
        initData();
    }

    private void initBundle() {
        Intent intent = getIntent();
        aMerchant=(Merchant) intent.getSerializableExtra("Merchant");
//        imgURL=aMerchant.getImage();
//        imageUrls = imgURL.split("\\|");
    }

    protected void initView() {
        titleBar = (SjtTitleBar) findViewById(R.id.title_bar);
//        gvImage = (GridView) findViewById(R.id.gv_image);
//        tCome = (TextView) findViewById(R.id.tv_mcome);
        mWVcontent = (WebView) findViewById(R.id.news_detail_webview );
    }

    protected void initEvent(){
        titleBar.setTitle(aMerchant.getShopName());
        titleBar.setLeftLayoutClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        WebSettings settings = mWVcontent.getSettings();
        settings.setJavaScriptEnabled(true);
//        settings.setBlockNetworkImage(false);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        mWVcontent.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                //TODO Auto-generated method stub
                //返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
                view.loadUrl(url);
                return true;
            }
        });
        mWVcontent.loadUrl(aMerchant.getDetailsUrl());
//        adapter = new QualificationAdapter(BusinessQualificationActivity.this, imageUrls, mQueue);
//        gvImage.setAdapter(adapter);
//        gvImage.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
//                Intent mIntent = new Intent(BusinessQualificationActivity.this, QualificationDetailActivity.class);
//                mIntent.putExtra(IBaseConstant.PICTURE_VIEWER_DEFAULT_POSTION, position);
//                mIntent.putExtra("username", aMerchant.getUserId().toString());
//                mIntent.putExtra(IBaseConstant.PICTURE_VIEWER_DATASOURCE, imageUrls);
//                startActivity(mIntent);
//            }
//        });
//        tCome.setText(aMerchant.getDesc());
    }

    protected void initData() {
    }

}
